__author__ = 'admin'

from socket import socket, AF_INET, SOCK_STREAM
import gvars

import base64

s=socket(AF_INET,SOCK_STREAM)
s.connect(('localhost',2000))
# s.sendall(b'hello\nzhoushuan1 \ncmd=shl.py \n zh=iiji\n optype=execute \n cmdline=echo.bat')

# s.sendall(b'hello\nzhoushuan1 \ncmd=shl.py \n zh=iiji\n optype=basecmd \n cmdline=ls')
cont='''
this is shell jaoben
hhddha
>>>
new line

'''
print cont

cont = base64.b64encode(cont)

print cont

# s.sendall(b'hello\nzhoushuan1 \nfilename=shl.py \n storepath=C:\\\n optype=uploadfile \n base64='+cont +'\n')
# s.send('\n'+Gvars.EOFSTR)

fout = s.makefile('w')
fout.write(b'hello\nzhoushuan1 \nfilename=shl.py \n storepath=C:\\\n  module=mod_uploadfile \n optype=uploadfile \n base64='+cont +'\n')
fout.write('\n'+gvars.EOFSTR+'\n')

fout.close()
print "fout closeed"

while True:
    rdata = s.recv(1024)
    if not rdata:
        break
    print rdata
s.close()